package com.chinawlx.wlxteacher.utils;

import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * 作者:吴名
 * 时间:16/8/2
 * 描述:TextView倒计时工具类
 */
public class TimerCountUtil extends CountDownTimer{
    private TextView mTv;
    private int mResIdCounting,mResIdFinished,mResIdTvColorCounting,mResIdTvColorFinished;
    public TimerCountUtil(long millisInFuture, long countDownInterval, TextView tv, int resIdCounting, int resIdFinished, int resIdTvColorCounting, int resIdTvColorFinished) {
        super(millisInFuture, countDownInterval);
        this.mTv = tv;
        mResIdCounting = resIdCounting;
        mResIdFinished = resIdFinished;
        mResIdTvColorCounting = resIdTvColorCounting;
        mResIdTvColorFinished = resIdTvColorFinished;
    }

    @Override
    public void onTick(long l) {
        mTv.setClickable(false);
        mTv.setText("重新发送("+l/1000+")");
        mTv.setBackgroundResource(mResIdCounting);
        mTv.setTextColor(mTv.getResources().getColor(mResIdTvColorCounting));
    }

    @Override
    public void onFinish() {
        mTv.setText("获取验证码");
        mTv.setClickable(true);
        mTv.setBackgroundResource(mResIdFinished);
        mTv.setTextColor(mTv.getResources().getColor(mResIdTvColorFinished));
    }
}
